home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EarthLink Network ExpressNet Suite
/
EarthLink Network ExpressNet Suite.iso
/
mac
/
WIN
/
SRFWATCH
/
WIN31
/
SURF.MS_
/
SURF.MS
Wrap
Text File
|
1995-08-19
|
12KB
|
492 lines
'**************************************************************************
'* SurfWatch Setup
'**************************************************************************
'$DEFINE DEBUG ''Define for script development/debugging
'$INCLUDE 'setupapi.inc'
'$INCLUDE 'msdetect.inc'
''Dialog ID's
CONST WELCOME = 100
CONST BADVERIFY = 200
CONST LEGALSTUFF = 300
CONST EXITFAILURE = 400
CONST REMOVER = 500
CONST EXITQUIT = 600
CONST EXITSUCCESS = 700
CONST OPTIONS = 800
CONST REMOVECANCEL = 900
CONST EXITUISUCCESS = 1000
CONST GETPASSWORD = 1100
CONST CONFIRMPSSWRD = 1200
CONST GETNAME = 1300
CONST EXITNOCHANGE = 1400
CONST SELECTDRIVE = 1500
CONST WINSOCKLOAD = 1600
CONST BADPASSWORD = 6000
''following were taken from windows.h. &H means they're hex
CONST WS_VISIBLE=&H10000000
CONST WS_BORDER =&H00800000
CONST WS_CLIPCHILDREN =&H02000000
CONST GWL_STYLE =-16
CONST SW_SHOWMAXIMIZED=3
DECLARE FUNCTION ShowWindow LIB "user.exe" (hWnd%,iShow%) AS INTEGER
DECLARE FUNCTION SetWindowLong LIB "user.exe" (hWnd%, offset%, style&) AS LONG
DECLARE FUNCTION WinExec LIB "kernel.exe" (szCmdLine$, wFlags%) AS INTEGER
DECLARE FUNCTION encrypt LIB "mscuistf.dll" (sz$) AS INTEGER
DECLARE FUNCTION SetFileAttr LIB "mscuistf.dll" (szFileName$,wAttr%) AS INTEGER
DECLARE FUNCTION SetWildAttr LIB "mscuistf.dll" (szFileName$,wAttr%) AS INTEGER
DECLARE FUNCTION KSW LIB "mscuistf.dll" () AS INTEGER
DECLARE FUNCTION KSU LIB "mscuistf.dll" () AS INTEGER
DECLARE FUNCTION Penguin LIB "mscuistf.dll" (sz$) AS INTEGER
DECLARE FUNCTION UnPenguin LIB "mscuistf.dll" () AS INTEGER
DECLARE FUNCTION Installed LIB "mscuistf.dll" () AS INTEGER
DECLARE FUNCTION InstallDrive LIB "mscuistf.dll" () AS INTEGER
DECLARE FUNCTION pmDeleteGroup LIB "mscuistf.dll" (szGroup$) AS INTEGER
DECLARE FUNCTION pmDeleteItem LIB "mscuistf.dll" (szItem$) AS INTEGER
DECLARE FUNCTION pmInitialize LIB "mscuistf.dll" () AS INTEGER
DECLARE FUNCTION pmUninitialize LIB "mscuistf.dll" () AS INTEGER
DECLARE FUNCTION Ostritch LIB "mscuistf.dll" (hWnd%) AS INTEGER
DECLARE FUNCTION Parrot LIB "mscuistf.dll" (sz$) AS INTEGER
DECLARE FUNCTION Budgie LIB "mscuistf.dll" (sz$) AS INTEGER
DECLARE FUNCTION Duck LIB "mscuistf.dll" () AS INTEGER
DECLARE FUNCTION Goose LIB "mscuistf.dll" () AS INTEGER
DECLARE FUNCTION WinVersionCheck LIB "mscuistf.dll" () AS INTEGER
''Bitmap ID
CONST LOGO = 1
GLOBAL DEST$ ''Default destination directory.
GLOBAL OPTCUR$ ''Option selection from option dialog.
GLOBAL DOSDIR$
GLOBAL Password$
GLOBAL EXENAME$
GLOBAL DLLNAME$
GLOBAL DESTDIR$
GLOBAL DESTDRIVE$
GLOBAL EXITREASON%
GLOBAL UserName$
DECLARE SUB Install
DECLARE SUB UnInstall
DECLARE SUB AddToRunLine
DECLARE SUB RemoveFromRunLine
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE FUNCTION GetFileFromPath(szPath$) AS STRING
INIT:
CUIDLL$ = "mscuistf.dll" ''Custom user interface dll
HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure
' Maximize the background window
hWnd%=HwndFrame()
i1&=SetWindowLong(hWnd%,GWL_STYLE,WS_VISIBLE+WS_BORDER+WS_CLIPCHILDREN)
j1%=ShowWindow(hWnd%,SW_SHOWMAXIMIZED)
SetBitmap CUIDLL$, LOGO
SetTitle "SurfWatch"
EXITREASON%=EXITSUCCESS
szInf$ = GetSymbolValue("STF_SRCINFPATH")
IF szInf$ = "" THEN
szInf$ = GetSymbolValue("STF_CWDDIR") + "SURF.INF"
END IF
ReadInfFile szInf$
szLegal$ = GetSymbolValue("STF_SRCINFPATH")
IF szLegal$ = "" THEN
szLegal$ = GetSymbolValue("STF_CWDDIR") + "LEGAL.TXT"
END IF
IF WinVersionCheck()=0 THEN
i% = DoMsgBox("This is the Windows 3.1 version of SurfWatch. Please contact 415-948-9505 for Windows 95 upgrade information.","ERROR",MB_OK+MB_ICONSTOP)
END
END IF
IF NOT EXISTS( szLegal$ ) THEN
i% = DoMsgBox("Cant open legal","ERROR",MB_OK)
GOTO QUIT
ENDIF
OPTCUR$ = "1"
DESTDRIVE$ = "C"
DESTDIR$ = ":\CO_RO_NT"
DOSDIR$ = "c:\dos\"
EXENAME$ = "SURFW.EXE"
DLLNAME$ = "SWUTIL.DLL"
UserName$ = ""
WELCOME:
sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc",0,"")
IF sz$ = "REACTIVATE" THEN
GOTO WELCOME
ENDIF
UIPop 1
' Check for reinstall
IF Installed() THEN
hWnd%=HwndFrame()
IF Ostritch(hWnd%)=0 THEN
EXITREASON%=EXITNOCHANGE
GOTO QUIT
END IF
END IF
IF Installed() = 0 THEN
GOTO LEGAL
END IF
OPTION:
SetSymbolValue "RadioDefault", OPTCUR$
OPTL1:
sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", 0, "")
OPTCUR$ = GetSymbolValue("ButtonChecked")
IF sz$ = "REACTIVATE" THEN
GOTO OPTL1
ENDIF
UIPop 1
IF OPTCUR$="2" THEN
GOTO DOUNINSTALL
ENDIF
LEGAL:
SetSymbolValue "EditTextIn" , szLegal$
LEGAL1:
sz$ = UIStartDlg(CUIDLL$, LEGALSTUFF, "FLegalDlgProc", 0, "")
IF sz$ = "CONTINUE" THEN
UIPop 1
ELSEIF sz$ = "REACTIVATE" THEN
GOTO LEGAL1
ELSE
EXITREASON%=EXITQUIT
GOTO QUIT
ENDIF
DRIVECHECK:
Drive% = InstallDrive()
IF (Installed()) AND (Drive%<>-1) THEN
DESTDRIVE$=CHR$(Drive%+ASC("a"))
ELSE
GetLocalHardDrivesList("Drives")
NumDrives% = GetListLength("Drives")
IF NumDrives%>1 THEN
SetSymbolValue "ListItemsIn" , GetSymbolValue("Drives")
SetSymbolValue "ListItemsOut" , GetListItem("Drives",1)
DRIVECHECK1:
sz$ = UIStartDlg(CUIDLL$, SELECTDRIVE, "FListDlgProc", 0,"")
IF sz$ = "CONTINUE" THEN
UIPop 1
DESTDRIVE$ = MID$(GetSymbolValue("ListItemsOut"),1,1)
ELSEIF sz$ = "REACTIVATE" THEN
GOTO DRIVECHECK1
ELSE
EXITREASON%=EXITQUIT
GOTO QUIT
END IF
ENDIF
ENDIF
DEST$ = DESTDRIVE$ + DESTDIR$
USERNAME:
SetSymbolValue "EditTextIn" , ""
USERNAME1:
sz$ = UIStartDlg(CUIDLL$, GETNAME, "FEditDlgProc", 0, "")
IF sz$ = "CONTINUE" THEN
UIPop 1
ELSEIF sz$ = "REACTIVATE" THEN
GOTO USERNAME1
ELSE
EXITREASON%=EXITQUIT
GOTO QUIT
END IF
UserName$ = GetSymbolValue( "EditTextOut" )
PASSWORD:
SetSymbolValue "EditTextIn", ""
PASSWORD1:
sz$ = UIStartDlg(CUIDLL$, GETPASSWORD, "FEditDlgProc", 0, "")
IF sz$ = "CONTINUE" THEN
UIPop 1
ELSEIF sz$ = "REACTIVATE" THEN
GOTO PASSWORD1
ELSE
EXITREASON%=EXITQUIT
GOTO QUIT
END IF
PassWord$ = GetSymbolValue("EditTextOut")
IF LEN(PassWord$) = 0 THEN
GOSUB BADPASSWORD
GOTO PASSWORD
ENDIF
PASSWORD2:
sz$ = UIStartDlg(CUIDLL$,CONFIRMPSSWRD,"FEditDlgProc", 0, "")
IF sz$ = "CONTINUE" THEN
UIPop 1
ELSEIF sz$ = "REACTIVATE" THEN
GOTO PASSWORD2
ELSE
EXITREASON%=EXITQUIT
GOTO QUIT
END IF
IF PassWord$ = GetSymbolValue("EditTextOut") THEN
GOTO DOINSTALL
ELSE
PASSWORD3:
sz$ = UIStartDlg(CUIDLL$,BADVERIFY,"FInfoDlgProc", 0, "")
IF sz$ = "CONTINUE" THEN
UIPop 1
ELSEIF sz$ = "REACTIVATE" THEN
GOTO PASSWORD3
ELSE
EXITREASON%=EXITQUIT
GOTO QUIT
END IF
GOTO PASSWORD
ENDIF
DOINSTALL:
Install
Path$ = DEST$ + "\surfu.exe"
i%=WinExec(Path$,1)
DOINSTALL2:
sz$ = UIStartDlg(CUIDLL$, EXITSUCCESS, "FInfo0DlgProc", 0, "")
IF sz$="REACTIVATE" THEN
GOTO DOINSTALL2
END IF
UIPop 1
END
DOUNINSTALL:
sz$ = UIStartDlg(CUIDLL$, REMOVER, "FInfoDlgProc", 0, "")
IF sz$="CONTINUE" THEN
UIPop 1
ELSEIF sz$="REACTIVATE" THEN
GOTO DOUNINSTALL
ELSE
UIPop 1
EXITREASON%=REMOVECANCEL
GOTO QUIT
END IF
Drive%=InstallDrive()
IF Drive%<>-1 THEN
DESTDRIVE$=CHR$(Drive%+ASC("a"))
ENDIF
DEST$ = DESTDRIVE$ + DESTDIR$
Uninstall
sz$ = UIStartDlg(CUIDLL$, EXITUISUCCESS , "FInfo0DlgProc",0,"")
UIPop 1
END
QUIT:
ON ERROR GOTO ERRQUIT
dlg% = EXITREASON
IF ERR THEN
dlg% = EXITFAILURE
END IF
QUITL1:
sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO QUITL1
END IF
UIPop 1
END
ERRQUIT:
i% = DoMsgBox("Setup data corrupted, contact SurfWatch", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
END
BADPASSWORD:
sz$ = UIStartDlg(CUIDLL$, BADPASSWORD, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO BADPASSWORD
END IF
UIPop 1
RETURN
'**
'** Purpose:
'** Builds the copy list and performs all installation operations.
'** Arguments:
'** none.
'** Returns:
'** none.
'*************************************************************************
SUB Install STATIC
i% = KSW()
i%= KSU()
i%=Parrot(DEST$)
SrcDir$ = GetSymbolValue("STF_SRCDIR")
CreateDir DEST$, cmoNone
AddSectionFilesToCopyList "Files", SrcDir$, DEST$
CopyFilesInCopyList
SysDir$ = GetWindowsSysDir()
Ctl3d$ = SysDir$ + "ctl3d.dll"
IF NOT EXISTS (Ctl3d$) THEN
ClearCopyList
AddSectionFilesToCopyList "SYSTEM", SrcDir$ , SysDir$
CopyFilesInCopyList
END IF
FileSpec$ = DEST$ + "\surfw.dat"
IF EXISTS( FileSpec$ ) THEN
RemoveFile FileSpec$, cmoNone
END IF
AddToRunLine
i% = encrypt(PassWord$)
PassWord$ = PassWord$
IniFile$ = GetWindowsDir() + "SURFW.INI"
CreateIniKeyValue IniFile$,"SurfWatch","Owner",UserName$,cmoOverwrite
CreateIniKeyValue IniFile$,"SurfWatch","Entry",PassWord$,cmoOverwrite
i%=Budgie(DEST$)
i%=Penguin(DEST$)
CreateProgmanGroup "startup","",cmoNone
ShowProgmanGroup "startup",6,cmoNone
Path$ = DEST$ + "\surfu.exe -s"
CreateProgmanItem "startup","SurfWatch Updater",Path$,"",cmoOverwrite
Path$ = DEST$ + "\surfw.exe"
CreateProgmanItem "startup","SurfWatch",Path$,"",cmoOverwrite
' Run SurfWatch
SurfW$ = DEST$ + "\" + EXENAME$
i%=WinExec(SurfW$,0)
END SUB
'**
'** Purpose:
'** Builds the copy list and performs all installation operations.
'** Arguments:
'** none.
'** Returns:
'** none.
'*************************************************************************
SUB UnInstall STATIC
i% = KSW()
i% = KSU()
i%=Parrot(DEST$)
i%=Duck()
' Erase all the files in the install directory
KillFileStr$ = DEST$ + "\*.*"
IF EXISTS(KillFileStr$) THEN
KILL KillFileStr$
ENDIF
TempDir$ = DESTDRIVE$ + ":\"
CHDIR TempDir$
IF DoesDirExist(DEST$) THEN
RMDIR DEST$
ENDIF
i%=Goose()
RemoveFromRunLine
i%=UnPenguin()
' Erase surfw.ini
IniFile$ = GetWindowsDir() + "SURFW.INI"
IF DoesFileExist (IniFile$,femExists) THEN
RemoveFile IniFile$, cmoNone
ENDIF
IF pmInitialize() THEN
CreateProgmanGroup "startup","",cmoNone
i% = pmDeleteItem("SurfWatch Updater")
i% = pmDeleteItem("SurfWatch")
i% = pmUninitialize()
ELSE
i%=DoMsgBox("Unable to remove Program Manager Items","SurfWatch Updater",MB_OK)
ENDIF
END SUB
'**
'** Purpose:
'** Appends a file name to the end of a directory path,
'** inserting a backslash character as needed.
'** Arguments:
'** szDir$ - full directory path (with optional ending "\")
'** szFile$ - filename to append to directory
'** Returns:
'** Resulting fully qualified path name.
'*************************************************************************
FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
IF szDir$ = "" THEN
MakePath = szFile$
ELSEIF szFile$ = "" THEN
MakePath = szDir$
ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
MakePath = szDir$ + szFile$
ELSE
MakePath = szDir$ + "\" + szFile$
END IF
END FUNCTION
FUNCTION GetFileFromPath(szPath$) STATIC AS STRING
' Find the last \
FOR i = LEN(szPath$) TO 1 STEP -1
IF MID$(szPath$,i,1)="\" THEN
GetFileFromPath = MID$(szPath,i+1)
i = 1
END IF
NEXT i
END FUNCTION
SUB AddToRunLine STATIC
RemoveFromRunLine
SurfW$ = DEST$ + "\" + EXENAME$
RunStr$ = GetIniKeyString( "WIN.INI", "windows", "load" )
RunStr$ = RunStr$ + " " + SurfW$
CreateIniKeyValue "WIN.INI", "windows" , "load" , RunStr$ , cmoOverwrite
END SUB
SUB RemoveFromRunLine STATIC
SurfW$ = DESTDIR$ + "\" + EXENAME$
RunStr$ = GetIniKeyString( "WIN.INI", "windows", "load" )
i% = INSTR( RunStr$ , SurfW$ )
IF NOT i%=0 THEN
i%=i%-1
SurfW$ = DESTDIR$ + "\" + EXENAME$
Temp$ = MID$( RunStr$ , 1 , i%-1 )
i% = i% + LEN( SurfW$ )
IF i%<LEN( RunStr$ ) THEN
Temp$ = Temp$ + MID$( RunStr$ , i% )
ENDIF
CreateIniKeyValue "WIN.INI","windows","load",Temp$,cmoOverwrite
ENDIF
END SUB